//api接口封装
function requestApi(ApiName, PostData,cb) {
  wx.request({
    url: ApiName,
    data: PostData,
    header: {
      'content-type': 'application/x-www-form-urlencoded',
      'version': 'v1',
      "token": wx.getStorageSync("token")
    },
    method: 'post',
    success: function (res) {
      typeof cb == "function" && cb(null, res)
      if(res.data.code == 0){
        wx.showToast({
          title:`${res.data.message}`,
          icon: "fail",
          duration: 1500
        });
        wx.clearStorage();
        setTimeout(function(){
          wx.redirectTo({
            url: '/pages/Portalpage/Portalpage',
          })
        }, 2000)
      }
    },
    fail: function (err) {
      typeof cb == "function" && cb(err)
    }
  })
}

//导出
module.exports = {
  requestApi,
}